package de.akad.imp03.client.ui;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.DockPanel;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HasVerticalAlignment;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.PushButton;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;

public class StartPage {

	public Widget onInitialize() {
		final VerticalPanel centerPanel = new VerticalPanel();
		final Label title = new Label ("Planspiel");
		final Label subject = new Label ("BEWERBERMANAGEMENT IM WEB 2.0");

		final PushButton bnStart = new PushButton(new Image("/img/bn_start.png"));
		final PushButton bnHelp = new PushButton(new Image("/img/bn_help.png"));
		final HorizontalPanel buttonPanel = new HorizontalPanel();
		
		title.addStyleName("title");
		subject.addStyleName("subject");
		buttonPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
		bnStart.addClickHandler(new ClickHandler() {
			
			@Override
			public void onClick(ClickEvent event) {
				WelcomePage p2 = new WelcomePage();
				RootPanel.get("mainPanel").clear();
				RootPanel.get("mainPanel").add(p2.onInitialize());
			}
		});
		buttonPanel.add(bnStart);
		buttonPanel.add(bnHelp);

		centerPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
		centerPanel.add(title);
		centerPanel.add(subject);
		
		final DockPanel main = new DockPanel();
		main.setWidth("60%");
		main.setHeight("100%");
		main.add(centerPanel, DockPanel.CENTER);
		main.setCellVerticalAlignment(centerPanel, HasVerticalAlignment.ALIGN_MIDDLE);
		main.setCellHorizontalAlignment(centerPanel, HasHorizontalAlignment.ALIGN_RIGHT);
		main.add(buttonPanel, DockPanel.SOUTH);
		main.setCellHorizontalAlignment(buttonPanel, HasHorizontalAlignment.ALIGN_RIGHT);
		
		return main;
	}
}
